package dong;


public class packbag {
	private int [] intpack = {34,26,98,76,32,15,56,24,5,7,14,40};
	private int index=0;
	private int fi=100;
	private  int Solution[] = new int[10];
	private int Sub;
	
	public void FindSolution(int Value){
		for(int a = 0; a<intpack.length; a++)
		{
	
			Sub=(intpack[a]-Value<0)? -(intpack[a]-Value) : intpack[a]-Value;
			if(fi>=Sub)
			{
				if(fi!=Sub)
				{
					Solution = new int[10];
					index=0;
				}
				fi=Sub;
				Solution[index]=intpack[a];
				index++;
			}
		
		}
	}
	
	public void LowestNumber(){
		int SolN=999;
		for(int a = 0; a<Solution.length; a++){
			if(Solution[a] != 0){
				if(Solution[a]<=SolN){
					SolN=Solution[a];
				}
			}
		}
		
		Solution= new int[10];
		Solution[0]=SolN;
	}
	
	public void HighestNumber(){
		int SolN=0;
		for(int a = 0; a<Solution.length; a++){
			if(Solution[a] != 0){
				if(Solution[a]>=SolN){
					SolN=Solution[a];
				}
			}
		}
		Solution= new int[10];
		Solution[0]=SolN;
	}

	
	public void Up_Sortin(){
		int SortSet[]= Solution;
		int tmp;
		for(int a = 0 ; a< SortSet.length; a++){
			if(SortSet[a]==0)
				continue;
			for(int b=a+1;b<SortSet.length;b++ ){
				if(SortSet[a]>=SortSet[b]){
					tmp=SortSet[a];
					SortSet[a]=SortSet[b];
					SortSet[b]=tmp;
				}
			}
		}
		Solution=SortSet;
	}
	
	public void Down_Sortin(){
		int SortSet[]= Solution;
		int tmp;
		for(int a = 0 ; a< SortSet.length; a++){
			if(SortSet[a]==0)
				continue;
			for(int b=a+1;b<SortSet.length;b++ ){
				if(SortSet[a]<=SortSet[b]){
					tmp=SortSet[a];
					SortSet[a]=SortSet[b];
					SortSet[b]=tmp;
				}
			}
		}
		Solution=SortSet;
	}
	
	public void PrintSolution()
	{
		System.out.print("Solution : ");
		for(int a=0; a<10;a++)
		{
			if(Solution[a]!=0){
				System.out.print(Solution[a]);
				System.out.print(' ');
			}
		}	
	}
	
	public void Find_Odd(){
		for(int a = 0; a<Solution.length;a++){
			if(Solution[a] == 0){
				continue;
			}
			else{
				if(Solution[a]%2!=1){
					Solution[a]=0;
				}
			}
		}
	}
	
	
	public void Find_NotOdd(){
		for(int a = 0; a<Solution.length;a++){
			if(Solution[a] == 0){
				continue;
			}
			else{
				if(Solution[a]%2==1){
					Solution[a]=0;
				}
			}
		}
	}
  
  	public static void main (String[] argc){
		packbag a = new packbag();
		a.FindSolution(35);
		//a.Find_NotOdd();
		//a.Find_Odd();
		//a.HighestNumber();
		//a.LowestNumber();
		//a.Up_Sortin();
		//a.Down_Sortin();
		a.PrintSolution();
	}
}
